const axios = require('axios');

// async function handle() {
//   let getdata = await axios({
//     url: 'http://geek.itheima.net/v1_0/mp/articles?page=10&per_page=10',
//     headers: {
//       Authorization: 'Bearer 3b9f761f-384b-4b22-bd1a-7708a864f357',
//     },
//   });

//   for (let index = 0; index < getdata.data.data.results.length; index++) {
//     del(getdata.data.data.results[index].id);
//   }
//   handle();
// }
// handle();

async function del(id) {
  let deldata = await axios({
    url: `http://geek.itheima.net/v1_0/mp/articles/${id}`,
    method: 'delete',
    headers: {
      Authorization: 'Bearer 3b9f761f-384b-4b22-bd1a-7708a864f357',
    },
  });
  console.log(deldata.data.message);
}

async function Add() {
  for (let index = 0; index < 100; index++) {
    let res = await axios({
      url: 'http://geek.itheima.net/v1_0/mp/articles?draft=false',
      method: 'post',
      data: {
        title: `正在为您报时:现在是北京时间${new Date().toLocaleTimeString()} `,
        channel_id: 0,
        content: `<p>当前时间时间戳为:${Date.now()}</p>`,
        cover: {
          type: 1,
          images: ['http://geek.itheima.net/uploads/1641384959154.png'],
        },
      },
      headers: {
        Authorization: 'Bearer 3b9f761f-384b-4b22-bd1a-7708a864f357',
      },
    });
    console.log(res.data.message);
  }
  Add();
  Add();
  Add();
}
Add();
